#include "bomb_debuff.h"

CBombDebuff::CBombDebuff()
    : CBuff(ENT_BUFF_BOMB,
          "buff_bomb",
          BUFF_TYPE_DEBUFF)
{
}

bool CBombDebuff::applyBuff(CPlayer *pPlayer)
{
    /**
     * Applies this debuff to a specific player. This debuff decreases the clip 
     * count on the player's clip by 1.
     * 
     * @param CPlayer *pPlayer The player to apply the debuff to.
     * @return bool Whether the debuff was applied
     */
    if (pPlayer->getActiveWeapon())
    {
        if (pPlayer->getActiveWeapon()->getID() == ENT_WEAPON_BOMB)
        {
            if (pPlayer->getActiveWeapon()->getClipCount() > 1)
            {
                // The player needs to be left with at least one bomb.
                pPlayer->getActiveWeapon()->setClipCount(
                    pPlayer->getActiveWeapon()->getClipCount() - 1);
                return true;
            }
        }
    }
    return false;
}

bool CBombDebuff::removeBuff(CPlayer *pPlayer)
{
    /**
     * Removes this debuff from a specific player. This increases the clip 
     * count on the player's clip by 1.
     * 
     * @param CPlayer *pPlayer The player to remove the buff from.
     * @return bool Whether the debuff was removed
     */
    if (pPlayer->getActiveWeapon())
    {
        if (pPlayer->getActiveWeapon()->getID() == ENT_WEAPON_BOMB)
        {
            pPlayer->getActiveWeapon()->setClipCount(
                pPlayer->getActiveWeapon()->getClipCount() + 1);
            return true;
        }
    }
    return false;
}